<?php
class ProductController extends ControllerBase {
	/*
	 * actionIndex
	 */
    public function actionIndex() {
    	// Init object
		$criteria 	= new CDbCriteria();

		// Get category
		$criteria->order = 'position DESC, id DESC';
		$criteria->addCondition('status != \'3\'');
		$objCategories 	= Categories::model()->findAll($criteria);

		$this->render('index', compact('objCategories'));
    }
    /*
	 * actionList
	 */
	public function actionList($id=null) {
    	// Init object
		$criteria 	= new CDbCriteria();

		// Get product
		if ($id != null) {
			$criteria->addCondition("category_id = {$id}");
		}
		$criteria->order = 'category_id DESC, id DESC';

		$objProducts 	= Products::model()->findAll($criteria);

		$this->render('list', compact('objProducts'));
    }
}